/*
 * @Author: 田鑫
 * @Date: 2023-03-05 18:59:18
 * @LastEditors: 田鑫
 * @LastEditTime: 2023-03-05 19:02:04
 * @Description: mock设置
 */

export default ({ mock, setup }: { mock?: boolean; setup: () => void }) => {
  if (mock !== false) setup();
};

export const successResponseWrap = (data: unknown) => {
  return {
    success: true,
    msg: '请求成功',
    code: 200,
    data,
    timestamp: new Date().getTime(),
  };
};

export const failResponseWrap = (data: unknown, msg: string, code = 50000) => {
  return {
    data,
    success: false,
    msg,
    code,
    timestamp: new Date().getTime(),
  };
};
